package com.dries.portal.admin.controller;

import com.dries.portal.admin.dto.UmsAdminParam;
import com.dries.portal.admin.entity.UmsAdmin;
import com.dries.portal.admin.service.IUmsAdminService;
import com.dries.portal.admin.service.IUmsRoleService;
import com.dries.security.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 后台用户表
 *
 * @author dries
 * @email samphsanie@gmail.com
 * @date 2020-09-22 18:23:26
 */
@Api(tags = "UmsAdminController", value = "后台用户管理")
@RestController
@RequestMapping("admin")
public class UmsAdminController {

    @Resource
    private IUmsAdminService adminService;
    @Resource
    private IUmsRoleService roleService;

    @ApiOperation(value = "用户注册")
    @PostMapping("/register")
    public CommonResult<UmsAdmin> register(@Validated @RequestBody UmsAdminParam umsAdminParam) {
        UmsAdmin umsAdmin = adminService.register(umsAdminParam);
        if (umsAdmin == null) {
            return CommonResult.failed();
        }
        return CommonResult.success(umsAdmin);
    }


//    /**
//     * 列表
//     */
//    @GetMapping("/list")
//    public CommonResult list(@RequestParam Map<String, Object> params){
//        return CommonResult.success();
//    }
//
//
//    /**
//     * 信息
//     */
//    @GetMapping("/info/{id}")
//    public CommonResult info(@PathVariable("id") Long id){
//		UmsAdmin umsAdmin = umsAdminService.getById(id);
//
//        return CommonResult.success();
//    }
//
//    /**
//     * 保存
//     */
//    @PostMapping("/save")
//    public CommonResult save(@RequestBody UmsAdmin umsAdmin){
//		umsAdminService.save(umsAdmin);
//
//        return CommonResult.success();
//    }
//
//    /**
//     * 修改
//     */
//    @PutMapping("/update")
//    public CommonResult update(@RequestBody UmsAdmin umsAdmin){
//		umsAdminService.updateById(umsAdmin);
//
//        return CommonResult.success();
//    }
//
//    /**
//     * 删除
//     */
//    @DeleteMapping("/delete")
//    public CommonResult delete(@RequestBody Long[] ids){
//		umsAdminService.removeByIds(Arrays.asList(ids));
//
//        return CommonResult.success();
//    }

}
